package com.link2room.rodimus.factory;

import com.link2room.common.exception.SysException;
import com.link2room.common.util.L2RAssert;
import com.link2room.common.util.SpringUtil;
import com.link2room.rodimus.constant.SignInConstant;
import com.link2room.rodimus.handler.ISignInDrawAwardHandler;

import static com.link2room.enums.exception.RodimusSysExceptionEnum.SIGN_IN_DRAW_AWARD;

/**
 * Created by LN on 2018/1/9
 */
public final class SignInDrawAwardHandlerFactory {

    public static ISignInDrawAwardHandler getHandler(String type){
        ISignInDrawAwardHandler handler = null;

        switch (type){
            case SignInConstant.AwardType.LOTTERY :
                handler = (ISignInDrawAwardHandler) SpringUtil.getBean("signInDrawAwardLotteryHandler");
                break;
            case SignInConstant.AwardType.PMSCOUPON :
                handler = (ISignInDrawAwardHandler) SpringUtil.getBean("sgnInDrawAwardPMSCouponHandler");
                break;
            case SignInConstant.AwardType.POINT :
                handler = (ISignInDrawAwardHandler) SpringUtil.getBean("signInDrawAwardPointHandler");
                break;
            default:
                handler = null;
        }
        L2RAssert.isTrue(null == handler,new SysException(SIGN_IN_DRAW_AWARD,"没有对应奖品类型[type] " + type));
        return handler;
    }
}
